package com.pdg.dungeondelver.defaulttheme.builders;

import com.pdg.dungeondelver.client.constants.BuilderConstants;
import com.pdg.dungeondelver.client.constants.GameConstants;
import com.pdg.dungeondelver.client.constants.PropertyGroupConstants;
import com.pdg.dungeondelver.engine.Layer;
import com.pdg.dungeondelver.engine.LayerCellBuilder;
import com.pdg.dungeondelver.engine.LayerColumn;
import com.pdg.dungeondelver.engine.LayerColumnBuilder;

public class DefaultLayerColumnBuilder implements LayerColumnBuilder{

	@Override
	public LayerColumn build(Layer theLayer) {
		LayerColumn column = new LayerColumn(theLayer);
		Integer rows = theLayer.getConfiguration().getPropertyGroups().get(PropertyGroupConstants.GAME_CONSTANTS).<Integer>get(GameConstants.LAYER_ROWS);
		LayerCellBuilder builder = theLayer.getConfiguration().getPropertyGroups().get(PropertyGroupConstants.BUILDERS).<LayerCellBuilder>get(BuilderConstants.LAYER_CELL_BUILDER);
		for(Integer index=0;index<rows;++index){
			column.put(index, builder.build(column));
		}
		return column;
	}

}
